/**
 * 岗位接口
 */
const Router = require("koa-router");
const router = new Router();
const { SysUserController } = require("../controller/sys_user.js");
const passport = require("koa-passport");
const auth = require("../middleware/auth.js");
const dataScope = require("../middleware/dataScope.js");

router.post(
  "/v1/system/user/login",
  SysUserController.login
);

router.post(
  "/v1/system/user/logout",
  // passport.authenticate("jwt", { session: false }),
  SysUserController.logout
);

router.post(
  "/v1/system/user/modifypwd",
  passport.authenticate("jwt", { session: false }),
  SysUserController.modifypwd
);

router.post(
  "/v1/system/user/userinfo",
  passport.authenticate("jwt", { session: false }),
  SysUserController.userInfo
);
// 新增 删除 修改 通过部门查用户 用户 绑定权限 查询 

router.post(
  "/v1/system/user/add",
  passport.authenticate("jwt", { session: false }),
  auth("system:user:add"),
  SysUserController.userAdd
);

router.post(
  "/v1/system/user/edit",
  passport.authenticate("jwt", { session: false }),
  auth("system:user:edit"),
  SysUserController.userUpd
);

router.post(
  "/v1/system/user/delete",
  passport.authenticate("jwt", { session: false }),
  auth("system:user:remove"),
  SysUserController.userDel
);

router.get(
  "/v1/system/user/list",
  passport.authenticate("jwt", { session: false }),
  auth("system:user:query"),
  dataScope,
  SysUserController.list
);

// 添加授权用户
router.post(
  "/v1/system/user/authRole/batchAddRole",
  passport.authenticate("jwt", { session: false }),
  SysUserController.batchAddUser
);

// 批量取消用户
router.post(
  "/v1/system/user/authRole/batchCancelRole",
  passport.authenticate("jwt", { session: false }),
  SysUserController.batchCancelRole
);

module.exports = router;
